package com.ruoyi.web.controller.book;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.module.business.JdSynLogBusiness;
import com.ruoyi.module.domain.JdSynLog;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 京东到家库存同步日志Controller
 * 
 * @author ruoyi
 * @date 2022-04-25
 */
@RestController
@RequestMapping("/system/log")
@RequiredArgsConstructor
public class JdSynLogController extends BaseController
{
    private final JdSynLogBusiness jdSynLogBusiness;

    /**
     * 查询京东到家库存同步日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:log:list')")
    @GetMapping("/list")
    public TableDataInfo list()
    {
        startPage();
        List<JdSynLog> list = jdSynLogBusiness.selectJdSynLogList();
        return getDataTable(list);
    }

    /**
     * 获取京东到家库存同步日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(jdSynLogBusiness.selectJdSynLogById(id));
    }

    /**
     * 修改京东到家库存同步日志
     */
    @PreAuthorize("@ss.hasPermi('system:log:edit')")
    @Log(title = "京东到家库存同步日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JdSynLog jdSynLog)
    {
        return toAjax(jdSynLogBusiness.updateJdSynLog(jdSynLog));
    }

    /**
     * 删除京东到家库存同步日志
     */
    @PreAuthorize("@ss.hasPermi('system:log:remove')")
    @Log(title = "京东到家库存同步日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(jdSynLogBusiness.deleteJdSynLogByIds(ids));
    }

    /**
     * 删除京东到家库存同步日志
     */
    @PreAuthorize("@ss.hasPermi('system:log:remove')")
    @Log(title = "京东到家库存同步日志", businessType = BusinessType.DELETE)
    @DeleteMapping("clear")
    public AjaxResult clear()
    {
        return toAjax(jdSynLogBusiness.clearJdSynLog());
    }
}
